<?php
	$sql="select * from php_orders where 1=1 ";
	if(!empty($_REQUEST['ordersn'])){
		$sql.=" and  ordersn like '%".$_REQUEST['ordersn']."%' ";
	}
	if(!empty($_REQUEST['delivery'])){
		$sql.=" and  delivery = ".$_REQUEST['delivery'];
	}
	$sql.=" order by orderid desc";
	
	//page start
	$db->query($sql);
	$page_total = $db->db_num_rows();
	$page_perpage = 5;
	$page_current = $_GET['page'] ? intval($_GET['page']) : 1;  //当前第几页
	if (strpos($_SERVER['REQUEST_URI'],'page=')){
		$page_url = preg_replace('/page=(\d+)/', 'page=#page#', $_SERVER['REQUEST_URI']);	
		} elseif (strpos($_SERVER['REQUEST_URI'],'?')){
		$page_url = $_SERVER['REQUEST_URI'] . '&page=#page#';
		} else {
		$page_url = $_SERVER['REQUEST_URI'] . '?page=#page#';
	}
	$page_html = page($page_total, $page_perpage, $page_current, $page_url, array('class' => 'pagenavi'));
	//page end
	
	$db->query($sql.' limit '.($page_current-1)*$page_perpage.','.$page_perpage);
	while($row = $db->fetch_array()){
		echo $row['orderid'];
	}
	
	echo $page_html; 